<?php
/**
 * Display basic page output for commandline scripts.
 *
 * Determines whether script is called from commandlien or not and shows
 * output accordingly.  Based on show and raw handlers.
 *
 * @reference
 * @reference http://tinyurl.com/y8q8xf4 (stackoverflow.com)
 *
 * @package		Handlers
 * @subpackage	Page
 * @version		$Id$
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @filesource
 *
 * @uses		Wakka::Format()
 *
 */

# Script Defaults
$CliHandlerDefaults = array(
    'non_cli_msg'   => 'This version is accessible only from the PHP CLI.'
);

# SCRIPT PARAMETERS
$is_cli = (php_sapi_name() == 'cli');
$raw    = (!empty($_GET['raw']))? (int) $this->GetSafeVar('raw', 'get') : 0;

# OUTPUT
$err_t = <<<XHTML
<div id="content">
    <p><em class="error">%s</em></p>
</div>
<!--closing page content-->
XHTML;

# Web-based, show error
if ( ! $is_cli ) {
    printf($err_t, $CliHandlerDefaults['non_cli_msg']);
}
elseif ( ! $this->page ) {
    print 'page not found';
}
else {
    echo $this->Format($this->page['body'], 'wakka', 'page');
}
?>
